import fetch from 'common/src/utils/fetch'

// 缴费人员维护信息
export function paymentStuInfo(studentId) {
    return fetch({
        url: `/api/studentservice/paymentlist/selectStudentInfoByStuId?studentId=${studentId}`,
        method: 'get'
    })
}

// 在校应收费设置名单列表
export function payConfigList(data) {
    return fetch({
        url: '/api/studentservice/paymentConfig/payConfigList',
        method: 'post',
        data
    })
}

// 在校应收费设置名单列表 新增、复制接口
export function addPayConfig(data) {
    return fetch({
        url: '/api/studentservice/paymentConfig/addPayConfig',
        method: 'post',
        data
    })
}

// 在校应收费设置名单列表 编辑接口
export function editPayConfig(data) {
    return fetch({
        url: '/api/studentservice/paymentConfig/editPayConfig',
        method: 'put',
        data
    })
}

// 在校应收费设置名单列表 删除接口
export function deletePayConfig(data) {
    return fetch({
        url: '/api/studentservice/paymentConfig/deletePayConfig',
        method: 'delete',
        data
    })
}


// 在校应收费设置名单列表 初始化名单接口
export function initPayment(data) {
    return fetch({
        url: '/api/studentservice/paymentConfig/initPayment',
        method: 'post',
        data
    })
}

// 在校应收费设置名单列表 初始化名单接口
export function payConditionName(data) {
    return fetch({
        url: `/api/studentservice/paymentConfig/payConditionName?keyWord=${data}`,
        method: 'get'
    })
}

// 应缴费名单维护 缴费名单列表
export function list(data) {
    return fetch({
        url: '/api/studentservice/paymentlist/list',
        method: 'post',
        data
    })
}

// 应缴费名单维护 新增接口
export function addPayment(data) {
    return fetch({
        url: '/api/studentservice/paymentlist/addPayment',
        method: 'post',
        data
    })
}

// 应缴费名单维护 编辑更新接口
export function updatePayment(data) {
    return fetch({
        url: '/api/studentservice/paymentlist/updatePayment',
        method: 'post',
        data
    })
}


// 应缴费名单维护 删除接口
export function deletePayment(data) {
    return fetch({
        url: '/api/studentservice/paymentlist/deletePayment',
        method: 'delete',
        data
    })
}

//  应缴费名单维护 导出接口
export function exportPaymentList(data = {}) {
    let keys = Object.keys(data).map(item => {return item;});
    let params = keys.reduce((prev, curr, index) => {
        prev += curr + '=' + data[curr];
        if (index < keys.length - 1) {
            prev += '&';
        }
        return prev;
    }, '');
    let url = '/api/studentservice/paymentlist/exportPaymentList';
    params && (url += `?${params}`);
    console.log(url, 'url');
    window.open(url);
}